package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.Acquisition;

public class AcquisitionValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return Acquisition.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "acquisitionId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "siteId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "channelId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "typeId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "acqName", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "status", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currNum", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currItem", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "totalItem", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pauseTime", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pageEncoding", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "queue", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "repeatCheckType", "required");
	}

}
